﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using hDualPane.Model;
using System.Collections.ObjectModel;
using hDualPane.Controller;

namespace hDualPane
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class MainFrame : Window
    {
        FileManager _fileManager;

        public MainFrame()
        {
            //Start up with both panels show C: Drive
            _fileManager = new FileManager("C:");
            InitializeComponent();
            stxtLeft.Text = "C:";
        }

        private void mnuTop_About_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("HxH Dual Panel File Manager",
                "About hDualPane",
                MessageBoxButton.OK,
                MessageBoxImage.Information);
        }

        private void toggleStatusBar(object sender, RoutedEventArgs e)
        {
            if ((sender as MenuItem).IsChecked)
            {
                rowMainStatus.Height = new GridLength(20);
            }
            else
            {
                rowMainStatus.Height = new GridLength(0);
            }
        }

        private void toggleCommandBar(object sender, RoutedEventArgs e)
        {
            if ((sender as MenuItem).IsChecked)
            {
                rowMainCommand.Height = new GridLength(20);
            }
            else
            {
                rowMainCommand.Height = new GridLength(0);
            }
        }

        private void exitApp(object sender, RoutedEventArgs e)
        {
            MessageBoxResult msgResult = MessageBox.Show("You are about to close hDualPane?",
                "Please confirm your action",
                MessageBoxButton.YesNo,
                MessageBoxImage.Question);

            switch (msgResult)
            {
                case MessageBoxResult.Yes:
                    this.Close();
                    break;
            }
        }

        private void itemClick(object sender, RoutedEventArgs e)
        {
            ListViewItem item = (sender as ListViewItem);
            FileSummary info = (item.Content as FileSummary);
            stxtLeft.Text = info.FileName;
            System.Diagnostics.Debug.Print(info.FileName);
        }

        public ObservableCollection<FileSummary> LeftList
        {
            get
            {
                return _fileManager.LeftList;
            }
        }

        public ObservableCollection<FileSummary> RightList
        {
            get
            {
                return _fileManager.RightList;
            }
        }
    }
}
